YUI.add("videoPlayer", function(Y) {
    var Lang = Y.Lang,
        Node = Y.Node; 
 
    /* VideoPlayer Events
     * participantBadge:rolledOver 
     */
    
    /* videoPlayer constructor */
    var VideoPlayer = function(config) {
        VideoPlayer.superclass.constructor.apply(this, arguments);
    } 
    VideoPlayer.NAME = "videoPlayer";
 
   
    /* Default VideoPlayer Attributes */
    VideoPlayer.ATTRS = {
      
    };
 	window.onYouTubePlayerReady = function (playerId) { 
 		Y.fire("youtubePlayerReady"); 
	};
    /* Extend the base Widget class */
    Y.extend(VideoPlayer, Y.Widget, {
 		
        /*
         * Initialization Code: Sets up privately used state
         * properties, and publishes the events VideoPlayer introduces
         */
        initializer : function(config) { 
            // Event handles - mouse over is set on the delegate
            // element, mousemove and mouseout are set on the trigger node
            this._player;
            this._eventHandles = { 
            };
 
            // Show/hide timers
            this._timer = {
            };
            
     		this.get("contentBox").set("innerHTML","<div id='videoPlayer'><h2>#</h2> <div id='ytapiplayer' ></div></div> ");
            Y.on("domready", Y.bind(this.initWidget , this));
            
            that = this;
        	Y.on("youtubePlayerReady" , function(){
            	that._player = document.getElementById("myytplayer");
            	//that.play('http://www.youtube.com/watch?v=691WAj8u5ko&feature=popular');
        	});
            
        }, 
     	initWidget : function() {      
		 
			var params = { allowScriptAccess: "always", bgcolor: "#cccccc" }; 
      		var atts = { id: "myytplayer" }; 
           // swfobject.embedSWF("http://www.youtube.com/v/ma9I9VBKPiw?border=0&amp;enablejsapi=1&amp;playerapiid=ytplayer", 
           swfobject.embedSWF("http://www.youtube.com/apiplayer?enablejsapi=1&playerapiid=ytplayer", 
            "ytapiplayer", "150", "150", "8", null, null, params, atts); 
            
            
    			var node = Y.get('#videoPlayer');
    			node.plug(Y.Plugin.Drag);
				node.dd.addHandle('h2');
     	},
     	
       onYouTubePlayerReady:function(playerId) {
           
        },
        
     	play : function(videoId)
     	{      		  
     		if(!this._player)return;    
          	this._player.loadVideoById(videoId, 0);  
          	//this._player.loadVideoByUrl('http://www.youtube.com/watch?v=rLoscbxjcwU&feature=featured', 0);
           	this._player.playVideo();
     	},
     
        /*
         * Destruction Code: Clears event handles, timers,
         * and current trigger information
         */
        destructor : function() { 
            this._clearTimers();
            this._clearHandles();
        },
 
        /*
         * bindUI is used to bind attribute change and dom event
         * listeners
         */
        bindUI : function() { 
           
        }, 
        /*
         * syncUI is used to update the rendered DOM, based on the current
         * VideoPlayer state
         */
        syncUI : function() {
          
        },
		parseMessage : function(message)
		{
			
		},
 	 
        /*
         * Cancel any existing show/hide timers
         */
        _clearTimers : function() {
           var timer = this._timer;
            
        },
 
        /*
         * Detach any stored event handles
         */
        _clearHandles : function() {
            var eventHandles = this._eventHandles;
 
        } 
        
    
    }); 
 
    //VideoPlayer = Y.Base.build(VideoPlayer.NAME, VideoPlayer, [Y.WidgetPosition, Y.WidgetStack], {dynamic:false});
	Y.VideoPlayer = VideoPlayer; 
//});
} , 0.1 );